home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr42 / soundss2.zip / SOUNDSYS.DOC < prev    next >
Text File  |  1994-08-24  |  15KB  |  433 lines

  1. ╔════════════════════════════════════════════════════════════╗
  2. ║                                                            ║
  3. ║ Sound System Source for your own productions (games&demos) ║
  4. ║                                                            ║
  5. ║ coded and provided in 1994 by the Frontman of Crew242 !!!  ║
  6. ║                                                            ║
  7. ╚════════════════════════════════════════════════════════════╝
  8.  
  9. RELEASE 2
  10.  
  11. Minor changes because of wrong config filename (sorry)!
  12. Took out the specific file-volume routines of Future Dimension.
  13.  
  14. Added one of my favourite modules that always reminds me on good ol' C-64.
  15. This is Thalamus.MOD by good ol' Rob Hubbard and converted by M. Simmonds.
  16.  
  17. ══════════════════════════════════════════════════════════════════════════════
  18.  
  19. This Sound System Source package includes:
  20.  
  21. SOUNDSYS.DOC  This file
  22.  
  23. USMOD.COM     Gravis UltraSound  module player, eg. USMOD CYBRNOID.MOD
  24. USMOD.ASM     Gravis UltraSound  player source
  25.  
  26. SBMOD.COM     SoundBlaster (Pro) module player, eg. SBMOD COMPLICA.MOD
  27. SBMOD.ASM     SoundBlaster (Pro) player source
  28.  
  29. SS.CFG        Configuration file
  30.  
  31.  
  32. Agreement:
  33.  
  34. This programs are free software only and may not be sold other than the cost
  35. of the disk or physical handling. You can redistribute it only in the same
  36. form as you have received it.
  37. This program is distributed WITHOUT ANY WARRANTY nor is it responsible for
  38. any damage of computer software and/or hardware.
  39.  
  40. ══════════════════════════════════════════════════════════════════════════════
  41.  
  42. What does this Sound System ?
  43.  
  44.  
  45. For Gravis UltraSound:
  46.  
  47. - 4/6/8 channels Protracker/Fasttracker module playing
  48.  
  49. - 5 channels for stereo FX
  50.  
  51. - Extended MOD effects support (Panning Effect E8)
  52.  
  53. - Mixing rate always 44100 Hz
  54.  
  55. - Always stereo
  56.  
  57. - Full 8/16-bit DMA support for sample upload (optional without)
  58.  
  59. - Max 1 MB GUS memory for samples
  60.  
  61. - 100% Assembler for high perfomance -> takes almost no cpu time
  62.  
  63. - Player needs only 12 KB and max 64 KB for Patterns
  64.  
  65.  
  66. For SoundBlaster (Pro/or any SB compatibles):
  67.  
  68. - 4/8 channels Protracker/Fasttracker module playing
  69.  
  70. - 1/2 channels on SB/SBPro for FX
  71.  
  72. - Full Protracker 2.1A effects support
  73.  
  74. - Mixing rates 10000 - 22222 Hz
  75.  
  76. - SBPro/SB16 stereo support
  77.  
  78. - 544 KB EMS Support for FX
  79.  
  80. - 100% Assembler for high perfomance -> takes only 10%-15% cpu time
  81.  
  82. - Player needs only 10 KB and 24 KB for DMA buffers
  83.  
  84. ══════════════════════════════════════════════════════════════════════════════
  85.  
  86. Where from, why, what for ?
  87.  
  88.  
  89. This Sound System has actually been developed for FUTURE DIMENSION of Crew242,
  90.  
  91. a new, commercial, neckbreaking shootem up game of the new generation.
  92.  
  93.  
  94. I decided to spread the Sound System as freeware (yes! the source is freeware)
  95.  
  96. because I dont like adlib neither midi sounds very much. Modules for everyone.
  97.  
  98. Anyway, modules produce the best sound and UltraSound is the best card for it.
  99.  
  100.  
  101. Use it in any manner for your productions. For major assimilations it is
  102.  
  103. necessary to change the source, eg. you need an object instead of a com-file,
  104.  
  105. you dont want to have a configuration file, etc.
  106.  
  107. This source is written for Borland Tasm 3.1 and its Tlink /t option for COMs.
  108.  
  109. ╔════════════════════════════════════════════════════════════════════════════╗
  110. ║                                                                            ║
  111. ║ All I want is a short credit in your production for the Sound System like: ║
  112. ║                                                                            ║
  113. ║ "Sound System by Frontman of Crew242" or "Sound System by Silvio Turello"  ║
  114. ║                                                                            ║
  115. ║ I will also do that for the pioneers of module sound. Thanks goes to:      ║
  116. ║                                                                            ║
  117. ║ Lars "Zap" Hamre    for inventing the protracker de facto standard         ║
  118. ║ (Amiga Freelancers)                                                        ║
  119. ║                                                                            ║
  120. ║ Joshua C. Jensen    for porting it to pc                                   ║
  121. ║ (Form. Renaissance)                                                        ║
  122. ║                                                                            ║
  123. ║ Serge Huber         for giving me a hint, how to make a SB-player          ║
  124. ║ (Numerus/Imphobia)                                                         ║
  125. ║                                                                            ║
  126. ║ Robert Adolfsson    for showing me, how to make a GUSPLAY (-er)            ║
  127. ║ (Robban/Cascada)                                                           ║
  128. ║                                                                            ║
  129. ║ Give always the complete package away !                                    ║
  130. ║                                                                            ║
  131. ║ If you want to be nice and you are allowed to give away a copy of your     ║
  132. ║                                                                            ║
  133. ║ production, I would really appreciate to get a copy of it just because     ║
  134. ║                                                                            ║
  135. ║ I am always interested in good sounding soft. I will of course respect     ║
  136. ║                                                                            ║
  137. ║ any requests not to spread the copy you send me. It will be exclusively    ║
  138. ║                                                                            ║
  139. ║ for the Frontman of Crew242. Refer to the address below:                   ║
  140. ║                                                                            ║
  141. ║ Silvio Turello, Giebeleichstr. 58, 8152 Glattbrugg, Switzerland            ║
  142. ║                                                                            ║
  143. ║ Tel.: ++/1/810 70 96    Fax: ++/1/810 85 63                                ║
  144. ║                                                                            ║
  145. ║ Email address until 1998: sturello@iiic.ethz.ch                            ║
  146. ║                                                                            ║
  147. ╚════════════════════════════════════════════════════════════════════════════╝
  148.  
  149. ══════════════════════════════════════════════════════════════════════════════
  150.  
  151. How ?
  152.  
  153.  
  154. Now it is time to give some technical details about the routines.
  155. The COM-format is quite unusual, but it has some important advantages,
  156. eg. you always now, what is going on, because you can load it in your own
  157. segment (at offset 100h) without relocating. the start address is 100h with
  158. a jump table for its functions. the functions can be reached with a far call
  159. to seg:104h, seg:108h, etc.
  160.  
  161. Here is an example, how the routines are handled in FUTURE DIMENSION:
  162.  
  163.  
  164. PLAYER HAS ALREADY BEEN LOADED TO A SEGMENT WITH OFFSET 100H.
  165. THE SEGMENT POINTER IS STORED IN MUSIC_SEG.
  166.  
  167. ;-----------------------------------------------------------------------------
  168.     CALL    CONFIG_INIT             ;GET CONFIG
  169. ; OPTIONAL SETTINGS
  170.     MOV     AX,22222                ;SET MAXIMUM SAMPLERATE
  171.     CALL    SET_SAMPLERATE
  172.     MOV     AL,255                  ;SET MAXIMUM VOLUME
  173.     MOV     BL,AL
  174.     MOV     BH,AL
  175.     CALL    SET_VOLUME
  176. ;-----------------------------------------------------------------------------
  177. ; INITIALIZING & STARTING
  178.     MOV     DX,OFFSET MOD_NAME      ;FIRST, TRY LOADING
  179.     CALL    LOAD_MOD
  180.     JNC     SHORT GM1
  181.     MOV     AH,9
  182.     MOV     DX,OFFSET ERROR1_TEXT
  183.     INT     21H
  184.     JMP     SHORT GM4
  185. GM1:    MOV     DX,OFFSET SAMPLE_NAME   ;GET SAMPLE
  186.     MOV     CL,80H                  ;PC-SAMPLE (00= AMIGA)
  187.     CALL    LOAD_SAMPLE
  188.     JNC     SHORT GM2
  189.     MOV     AH,9
  190.     MOV     DX,OFFSET ERROR2_TEXT
  191.     INT     21H
  192. GM2:    CALL    PLAY_MUSIC              ;TRY STARTING
  193.     JNC     SHORT GM3
  194.     MOV     AH,9
  195.     MOV     DX,OFFSET ERROR3_TEXT
  196.     INT     21H
  197.     JMP     SHORT GM4
  198. ;-----------------------------------------------------------------------------
  199. ; THIS COULD BE THE MAIN ROUTINE
  200. GM3:    MOV     AH,9
  201.     MOV     DX,OFFSET OUT_TEXT
  202.     INT     21H
  203. LM1:    XOR     AH,AH
  204.     INT     16H
  205.     CMP     AL,27
  206.     JE      SHORT GM5
  207.     CMP     AL,"+"
  208.     JNE     SHORT G1
  209.     CALL    GET_VOLUME
  210.     INC     AL
  211.     CALL    SET_VOLUME
  212.     JMP     LM1
  213. G1:     CMP     AL,"-"
  214.     JNE     SHORT G2
  215.     CALL    GET_VOLUME
  216.     DEC     AL
  217.     CALL    SET_VOLUME
  218.     JMP     LM1
  219. G2:     CMP     AL,"9"
  220.     JNE     SHORT G3
  221.     MOV     AL,0
  222.     CALL    SET_SONGLOOP
  223.     JMP     LM1
  224. G3:     CMP     AL,"0"
  225.     JNE     SHORT G4
  226.     CALL    GET_SONGMOD
  227.     INC     AL
  228.     CALL    SET_SONGMOD
  229.     JMP     LM1
  230. G4:     CMP     AL,"1"
  231.     JNE     LM1
  232.     MOV     BX,0                    ;HANDLE
  233.     MOV     CX,22222                ;FREQUENCE
  234.     CALL    PLAY_SAMPLE
  235.     JMP     LM1
  236. ;-----------------------------------------------------------------------------
  237. ; CUTTING OFF
  238. GM5:    CALL    STOP_MUSIC              ;STOP MUSIC
  239. GM4:    CALL    END_SAMPLE              ;UNLOAD SAMPLES
  240.     CALL    END_MUSIC               ;UNLOAD MUSIC
  241. ;-----------------------------------------------------------------------------
  242.  
  243. FUNCTION LIBRARY:
  244.  
  245. MUSIC_CALL      DW 0
  246. MUSIC_SEG       DW 0
  247. ;-----------------------------------------------------------------------------
  248. CONFIG_INIT:
  249.     MOV     BP,104H
  250.     JMP     NEXT_STEP
  251. LOAD_MOD:
  252.     MOV     BP,108H
  253.     JMP     NEXT_STEP
  254. PLAY_MUSIC:
  255.     MOV     BP,10CH
  256.     JMP     NEXT_STEP
  257. STOP_MUSIC:
  258.     MOV     BP,110H
  259.     JMP     NEXT_STEP
  260. END_MUSIC:
  261.     MOV     BP,114H
  262.     JMP     NEXT_STEP
  263. LOAD_SAMPLE:
  264.     MOV     BP,118H
  265.     JMP     NEXT_STEP
  266. PLAY_SAMPLE:
  267.     MOV     BP,11CH
  268.     JMP     NEXT_STEP
  269. END_SAMPLE:
  270.     MOV     BP,120H
  271.     JMP     NEXT_STEP
  272. SET_SAMPLERATE:                         ;SB ONLY
  273.     MOV     BP,124H
  274.     JMP     NEXT_STEP
  275. GET_VOLUME:
  276.     MOV     BP,128H
  277.     JMP     NEXT_STEP
  278. SET_VOLUME:
  279.     MOV     BP,12CH
  280.     JMP     NEXT_STEP
  281. SET_SONGLOOP:
  282.     MOV     BP,130H
  283.     JMP     NEXT_STEP
  284. GET_SONGPOSITION:
  285.     MOV     BP,134H
  286.     JMP     NEXT_STEP
  287. SET_SONGPOSITION:
  288.     MOV     BP,138H
  289.     JMP     NEXT_STEP
  290. GET_SONGMOD:
  291.     MOV     BP,13CH
  292.     JMP     NEXT_STEP
  293. SET_SONGMOD:
  294.     MOV     BP,140H
  295.     JMP     NEXT_STEP
  296. DSP_OFF:
  297.     MOV     BP,144H
  298.     JMP     NEXT_STEP
  299. DSP_RESET:
  300.     MOV     BP,148H
  301.     JMP     NEXT_STEP
  302.  
  303. NEXT_STEP:
  304.     MOV     MUSIC_CALL,BP
  305.     PUSHA
  306.     PUSH    DS
  307.     CALL    DWORD PTR DS:[MUSIC_CALL]
  308.     POP     DS
  309.     POPA
  310.     RET
  311.  
  312. ══════════════════════════════════════════════════════════════════════════════
  313.  
  314. It is handier to combine some functions to a logical group as below:
  315.  
  316. proc start_music(x,y,z...)
  317.  
  318.     is the player already in memory?
  319.     if not then load player and
  320.     CALL CONFIG_INIT               IF CARRY RETURNED IS 1 THEN ERROR
  321.  
  322.     load module x
  323.     CALL LOAD_MOD                  DS:DX IS FILENAME
  324.                        IF CARRY RETURNED IS 1 THEN ERROR
  325.  
  326.     load optional FX samples y,z,...
  327.     CALL LOAD_SAMPLE               DS:DX IS FILENAME
  328.                        CL=80H PC SAMPLE, 00H AMIGA SAMPLE
  329.                        AX RETURNS A HANDLE (0,2,4,6,..)
  330.                        IF CARRY RETURNED IS 1 THEN ERROR
  331.  
  332.     set optional volume, songloop, samplerate, soundmod
  333.     CALL GET_VOLUME                \ AL=MASETR_VOLUME
  334.     CALL SET_VOLUME                / BL=MUSIC_VOL, BH=FX_VOL
  335.     CALL SET_SONGLOOP              AL=PATTERN ORDER, >127 IS NO LOOP
  336.     CALL SET_SAMPLERATE            AX=RATE 10000-22222
  337.     CALL GET_SONGMOD               \ AL=0 MUSIC & FX
  338.     CALL SET_SONGMOD               /   =1 MUSIC, =2 FX, =3 NOTHING
  339.  
  340.     start playing
  341.     CALL PLAY_MUSIC                IF CARRY RETURNED IS 1 THEN ERROR
  342.  
  343.     get or set optional current songposition (only valid if music is playing)
  344.     CALL GET_SONGPOSITION          \ AL=0..127
  345.     CALL SET_SONGPOSITION          /
  346.  
  347. end start_music
  348.  
  349.  
  350. proc quit_music
  351.  
  352.     stop playing                       It is no problem to restart again
  353.     CALL STOP_MUSIC
  354.  
  355.     unload FX samples                  I do not recommend to reload fx samples
  356.     CALL END_SAMPLE                before unloading module
  357.  
  358.     unload module data
  359.     CALL END_MUSIC
  360.  
  361. end quit music
  362.  
  363.  
  364. now it is very easy to use:
  365.  
  366.     call start_music
  367.  
  368.     start optional FX
  369.     CALL PLAY_SAMPLE               BX= HANDLE, CX= FREQUENCY
  370.  
  371.     call quit_music
  372.  
  373.     call start_music
  374.  
  375.     call quit_music
  376.  
  377.     etc.
  378.  
  379. kill player                            Do not forget to remove player segment
  380.  
  381. ══════════════════════════════════════════════════════════════════════════════
  382.  
  383. The players use a 1024 Hz interrupt generated by the timer or by the realtime
  384. clock. If it is the timer, the old irq is chained at the normal frequency.
  385. Most options can be set in the SS.CFG configuration file.
  386.  
  387. The SoundBlaster player uses in this version 544 KB EMS for FX and only
  388. conventional memory to hold the whole module. It should be no problem to
  389. use EMS for the module data too.
  390.  
  391. Both players (SB/SBPro and GUS) are very stable. That means, that they wont
  392. crash because of a wrong baseport, irq, dma, etc.
  393. It may happen that DMA stops after use of Playfile or some other players.
  394. In this case start ultrinit before using usmod.
  395. If you encounter problems, remember that the interface does never recover
  396. any registers especially es, ds segment registers because it is speed
  397. and memory optimized code. 
  398.  
  399. The players dont use the MOD patterns as internal format because of too many
  400. repetitions in channels. The loader splits up the patterns into tracks for
  401. each channel and generates instead of the pattern order table a track order
  402. table for each channel. That means, if a channel plays always the same like
  403. a drum channel, it needs just the memory of one track. It is similar to the
  404. MTM format. The differences between MOD and MTM's memory requirements for the
  405. same song can range from 20 to over 100 KB.
  406. The SB/SBPro player precalculates most periods to notes. Refer to the
  407. actual SB/SBPro loader for more details about the internal format.
  408.  
  409. If you have some experience with assembler, you can change following parts
  410. very easily:
  411.  
  412. - proc config_init    sets all config variables. You can exchange it with
  413.               a selfdetecting routine, a menu  or a set variable
  414.  
  415. - proc load_mod       change the first lines to assimilate to your
  416.   proc load_sample    own filesystem
  417.  
  418. - loader              you can implement loader for your own format
  419.  
  420. - interfaces          no problem to assimilate
  421.  
  422. - additional functions, eg. peeks for volume bars
  423.               implement some additional functions to allow access to
  424.               internal variables while playing.
  425.  
  426. ══════════════════════════════════════════════════════════════════════════════
  427.  
  428. Happy coding...
  429.  
  430. Frontman of Crew242
  431.  
  432. ══════════════════════════════════════════════════════════════════════════════
  433.